#!/bin/sh

# This script is called on startup to remap keys.
# Decrease key repeat delay to 200ms and increase key repeat rate to 100 per second.
xset r rate 200 100
# Map the caps lock key to super, and map the menu key to right super.
setxkbmap -option caps:super,altwin:menu_win
# When caps lock is pressed only once, treat it as escape.
killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape'
# Turn off the caps lock if on since there is no longer a key for it.
xset -q | grep "Caps Lock:\s*on" && xdotool key Caps_Lock

case $(tty) in
        "/dev/tty"*)
                echo -e "$(dumpkeys | grep ^keymaps)\nkeycode 58 = Escape" | doas loadkeys
        ;;
esac

